# Author: HZT
# Date: 2023/8/26
import time
import page
from base.base import Base
from utils import click_paste_img


class WebSkTop(Base):
    # 获取余额
    def sk_top_get_ye(self):
        return self.base_get_text(page.web_sk_top_ye)

    # 获取授信余额
    def sk_top_get_sxye(self):
        return self.base_get_text(page.web_sk_top_sxye)

    # 获取转账码
    def sk_top_get_zzm(self):
        return self.base_get_text(page.web_sk_top_zzm)

    # 点击转账码
    def sk_top_click_zzm(self):
        self.base_click(page.web_sk_top_zzm)

    # 获取转账码弹窗
    def sk_top_get_zzmtc(self):
        return self.base_get_text(page.web_sk_top_zzmtc)

    #

    # 点击转账
    def sk_top_click_zz(self):
        self.base_find_first(page.web_sk_top_zz).click()

    # 点击去充值
    def sk_top_click_qcz(self):
        self.base_click(page.web_sk_top_qcz)

    # 点击刷新
    def sk_top_click_sx(self):
        self.base_click(page.web_sk_top_sx)

    # 点击头像
    def sk_top_click_tx(self):
        self.base_finds(page.web_sk_top_tx)[0].click()

    # 点击设置
    def sk_top_click_sz(self):
        self.base_finds(page.web_sk_top_sz)[0].click()

    # 点击登出
    def sk_top_click_dc(self):
        self.base_finds(page.web_sk_top_dc)[0].click()

    # 输入收款人转账码
    def sk_top_input_skrzzm(self, code):
        self.base_finds(page.web_sk_top_sr)[0].clear()
        self.base_finds(page.web_sk_top_sr)[0].send_keys(code)

    # 输入金额
    def sk_top_input_je(self, money):
        self.base_finds(page.web_sk_top_sr)[1].clear()
        self.base_finds(page.web_sk_top_sr)[1].send_keys(money)

    # 输入备注
    def sk_top_input_bz(self, text):
        self.base_finds(page.web_sk_top_sr)[2].clear()
        self.base_finds(page.web_sk_top_sr)[2].send_keys(text)

    # 获取收款人信息
    def sk_top_get_skr(self):
        return self.base_get_text(page.web_sk_top_skr)

    # 获取转账弹窗内容
    def sk_top_get_zztc(self):
        return self.base_get_text(page.web_sk_top_zztc)

    # 点击立即转账
    def sk_top_click_ljzz(self):
        self.base_click(page.web_sk_top_ljzz)

    # 获取用户名
    def sk_top_get_yhm(self):
        return self.base_get_text(page.web_sk_top_yhm)

    # 输入名称
    def sk_top_input_mc(self, name):
        self.base_input(page.web_sk_top_mc, name)

    # 输入密码
    def sk_top_input_mm(self, pwd):
        self.base_input(page.web_sk_top_mm, pwd)

    # 输入确认密码
    def sk_top_input_qrmm(self, qr_pwd):
        self.base_input(page.web_sk_top_qrmm, qr_pwd)

    # 点击提交按钮
    def sk_top_click_tj(self):
        self.base_click(page.web_sk_top_tj)

    # 获取设置弹窗内容
    def sk_top_get_sztc(self):
        return self.base_find(page.web_sk_top_sztc)

    # 获取公司名称+角色
    def sk_top_get_gsmc_js(self):
        return self.base_get_text(page.web_sk_top_gsmc_js)

    # 点击转账码确认
    def sk_top_click_zzmqr(self):
        self.base_click(page.web_sk_top_zzmqr)

    # 点击转账文字
    def sk_top_click_zzwz(self):
        self.base_finds(page.web_sk_top_zzwz)[0].click()

    # 点击转账确定
    def sk_top_click_zzqd(self):
        self.base_click(page.web_sk_top_zzqd)

    # 获取转账截图的元素
    def sk_top_get_zzjt(self):
        return self.base_find_first(page.web_sk_top_zzjt)

    # 点击银行名
    def sk_top_click_yhm(self, yhm):
        self.base_click(page.create_web_sk_top_cz_selector(yhm))

    # 点击充值金额
    def sk_top_click_czje(self):
        self.base_click(page.web_sk_top_czje)

    # 输入充值金额
    def sk_top_input_srje(self, text):
        self.base_input(page.web_sk_top_srje, text)

    # 点击创建新充值
    def sk_top_click_cjcz(self):
        self.base_click(page.web_sk_top_cjcz)

    # 点击备注
    def sk_top_click_czbz(self):
        self.base_click(page.web_sk_top_czbz)

    # 输入备注
    def sk_top_input_czbz(self, text):
        self.base_input(page.web_sk_top_srbz, text)

    # 获取充值图片元素
    def sk_top_get_cztp(self):
        return self.base_find(page.web_sk_top_cztp)

    # 点击确认完成上传
    def sk_top_click_qrsc(self):
        self.base_click(page.web_sk_top_qrsc)

    # 获取打款成功内容
    def sk_top_get_dkcg(self):
        return self.base_get_text(page.web_sk_top_dkcg)

    # 组合转账功能
    def sk_top_zz(self, code, money, text, *driver):
        time.sleep(0.5)
        self.sk_top_input_je(money)
        time.sleep(1)
        self.sk_top_input_skrzzm(code)
        time.sleep(1)
        self.sk_top_input_bz(text)
        if driver:
            click_paste_img("test001.png", self.sk_top_get_zzjt(), *driver)
        time.sleep(2)
        self.sk_top_click_ljzz()

    # 组合账号编辑设置功能
    def sk_top_sz(self, name, pwd, qr_pwd):
        self.sk_top_click_tx()
        time.sleep(1)
        self.sk_top_click_sz()
        time.sleep(1)
        self.sk_top_input_mc(name)
        time.sleep(1)
        self.sk_top_input_mm(pwd)
        time.sleep(1)
        self.sk_top_input_qrmm(qr_pwd)
        time.sleep(1)
        self.sk_top_click_tj()
        time.sleep(1)

    # 组合充值功能
    def sk_top_cz(self, driver, yhm, je, filename, bz=None):
        self.sk_top_click_yhm(yhm)
        time.sleep(0.5)
        self.sk_top_input_srje(je)
        self.sk_top_click_cjcz()
        time.sleep(0.5)
        if bz:
            self.sk_top_input_czbz(bz)
        click_paste_img(filename, self.sk_top_get_cztp(), driver)
        self.sk_top_click_qrsc()
